From 701ea937cc56993d8df3619a814d4231ef122edc Mon Sep 17 00:00:00 2001 From: "mwilli2@equilibrium.research" Date: Wed, 15 Sep 2004 16:19:13 +0000 Subject: [PATCH] bitkeeper revision 1.1159.76.4 (41486b81LlL7eGHBxdKlHNQ3D64MYA) Restore xendomains script. --- .rootkeys | 1 + tools/examples/init.d/xendomains | 146 +++++++++++++++++++++++++++++++ 2 files changed, 147 insertions(+) create mode 100755 tools/examples/init.d/xendomains diff --git a/.rootkeys b/.rootkeys index 1299c323ba..8725479d09 100644 --- a/.rootkeys +++ b/.rootkeys @@ -310,6 +310,7 @@ 401d7e160vaxMBAUSLSicuZ7AQjJ3w tools/examples/Makefile 401d7e16UgeqroJQTIhwkrDVkoWgZQ tools/examples/README 405ff55dawQyCHFEnJ067ChPRoXBBA tools/examples/init.d/xend +40278d94cIUWl2eRgnwZtr4hTyWT1Q tools/examples/init.d/xendomains 40ee75a9xFz6S05sDKu-JCLqyVTkDA tools/examples/network 40ee75a967sxgcRY4Q7zXoVUaJ4flA tools/examples/vif-bridge 40ee75a93cqxHp6MiYXxxwR5j2_8QQ tools/examples/xend-config.sxp diff --git a/tools/examples/init.d/xendomains b/tools/examples/init.d/xendomains new file mode 100755 index 0000000000..41524e6f57 --- /dev/null +++ b/tools/examples/init.d/xendomains @@ -0,0 +1,146 @@ +#!/bin/sh +# +# /etc/init.d/xendomains +# Start / stop domains automatically when domain 0 boots / shuts down. +# +# chkconfig: 345 99 00 +# description: Start / stop Xen domains. +# +# This script offers fairly basic functionality. It should work on Redhat +# but also on LSB-compliant SuSE releases and on Debian with the LSB package +# installed. (LSB is the Linux Standard Base) +# +# Based on the example in the "Designing High Quality Integrated Linux +# Applications HOWTO" by Avi Alkalay +# +# + +RETVAL=0 + +INITD=/etc/init.d/ + +AUTODIR=/etc/xen/auto +LOCKFILE=/var/lock/subsys/xendomains + +if [ -e /lib/lsb ]; then + # assume an LSB-compliant distro (Debian with LSB package, + # recent-enough SuSE, others...) + + . /lib/lsb/init-functions # source LSB standard functions + + on_fn_exit() + { + if [ $RETVAL -eq 0 ]; then + log_success_msg + else + log_failure_msg + fi + } +else + # assume a Redhat-like distro + . $INITD/functions # source Redhat functions + + on_fn_exit() + { + if [ $RETVAL -eq 0 ]; then + success + else + failure + fi + + echo + } +fi + + + +start() { + if [ -f $LOCKFILE ]; then return; fi + + echo -n $"Starting auto Xen domains:" + + # We expect config scripts for auto starting domains to be in + # AUTODIR - they could just be symlinks to files elsewhere + if [ -d $AUTODIR ] && [ $(ls $AUTODIR | wc -l) -gt 0 ]; then + touch $LOCKFILE + + # Create all domains with config files in AUTODIR. + for dom in $AUTODIR/*; do + xm create --quiet --defaults $dom + if [ $? -ne 0 ]; then + RETVAL=$? + fi + done + + fi + + on_fn_exit +} + +stop() +{ + # NB. this shuts down ALL Xen domains (politely), not just the ones in + # AUTODIR/* + # This is because it's easier to do ;-) but arguably if this script is run + # on system shutdown then it's also the right thing to do. + + echo -n $"Shutting down all Xen domains:" + + xm shutdown --all --wait --norestart + + RETVAL=$? + + [ $RETVAL -eq 0 ] && rm -f $LOCKFILE + + on_fn_exit +} + +# This does NOT necessarily restart all running domains: instead it +# stops all running domains and then boots all the domains specified in +# AUTODIR. If other domains have been started manually then they will +# not get restarted. +# Commented out to avoid confusion! +# +#restart() +#{ +# stop +# start +#} + +# same as restart for now - commented out to avoid confusion +#reload() +#{ +# restart +#} + + +case "$1" in + start) + start + ;; + + stop) + stop + ;; + +# The following are commented out to disable them by default to avoid confusion +# - see the notes above +# +# restart) +# restart +# ;; +# +# reload) +# reload +# ;; + + status) + xm list + ;; + + *) + echo $"Usage: $0 {start|stop|status}" + ;; +esac + +exit $RETVAL -- 2.30.2